package com.wl.dzt.sys.ui.ext.view;

import com.wl.dzt.sys.controller.result.ActionResult;
import com.wl.dzt.sys.controller.result.FormResult;
import com.wl.dzt.sys.controller.view.View;
import com.wl.dzt.sys.util.WebUtils;
import com.wl.dzt.sys.util.json.Json;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author wl_code@163.com
 * @version 1.0
 * @date 2018/7/5/005
 * @description ext表单视图
 */
@Component
public class ExtFormView implements View {

    /**
     * <b>表单视图</b>

     *
     * @param actionResult
     * @param response
     * @param request
     * @return
     */
    public String doView(ActionResult actionResult, HttpServletResponse response, HttpServletRequest request) {
        FormResult formResult = actionResult.getFormResult();
        request.setAttribute("success", formResult.getSuccess());
        WebUtils.print(Json.parse(formResult), response);
        return null;
    }

}
